package com.qili.service.jc.impl;

import com.qili.base.mapper.BaseMapper;
import com.qili.base.service.impl.BaseServiceImpl;
import com.qili.entity.jc.JcProjectStage;
import com.qili.entity.jc.dto.JcProjectStageDTO;
import com.qili.mapper.jc.JcProjectStageMapper;
import com.qili.service.jc.JcProjectStageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @author zhaoyongke
 * @date 2020/11/3
 * @description
 */
@Service
public class JcProjectStageServiceImpl extends BaseServiceImpl<JcProjectStage, String> implements JcProjectStageService {


    @Autowired
    private JcProjectStageMapper jcProjectStageMapper;

    @Override
    public BaseMapper<JcProjectStage, String> getMappser() {
        return jcProjectStageMapper;
    }


    @Override
    public List<JcProjectStageDTO> selectProjectStage(JcProjectStageDTO dto) {
        List<JcProjectStageDTO> list = jcProjectStageMapper.selectProjectStage(dto);
        return list;

    }
    /**
    * @Author:zhaoyongke
    * @Description: 查询最大值排序编号
    * @param dto
    * @Date:11:13 2021/1/8
    */
    @Override
    public Integer selectProjectStageMaxOrderNum(JcProjectStageDTO dto) {
        Integer orderNum= jcProjectStageMapper.selectProjectStageMaxOrderNum(dto);
        return orderNum;

    }
    @Override
    public int insert(JcProjectStage supervisorProjectStage) {
        return jcProjectStageMapper.insert(supervisorProjectStage);
    }

    @Override
    public List<JcProjectStage> getFinishedStages(JcProjectStage stage) {
        Example example = new Example(JcProjectStage.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("projectId",stage.getProjectId());
        criteria.andEqualTo("finishStatus","2");
        Example.Criteria criteria1 = example.createCriteria();
        criteria1.orEqualTo("id",stage.getId());
        example.or(criteria1);
        List<JcProjectStage> allFinishedStage = jcProjectStageMapper.selectByExample(example);
        return allFinishedStage;
    }
    @Override
    public int deleteByProjectIds(String[] ids) {
        return jcProjectStageMapper.deleteByProjectIds(ids);
    }

    @Override
    public int getNotFinishedStageCount(JcProjectStage stage) {
        return jcProjectStageMapper.getNotFinishedStageCount(stage);
    }

}
